package com.zdp.strategy.service.oss;

import com.zdp.common.enums.ChannelType;
import com.zdp.strategy.entity.req.OssChannelReq;
import com.zdp.strategy.entity.resp.OssChannelResp;
import com.zdp.strategy.handler.AbstractChannelStrategy;
import com.zdp.strategy.handler.AbstractService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class AlibabaOssServiceHandler extends AbstractService<OssChannelReq, OssChannelResp> {

    public AlibabaOssServiceHandler(List<AbstractChannelStrategy<OssChannelReq, OssChannelResp>> abstractChannelStrategies) {
        super(abstractChannelStrategies);
    }

    @Override
    protected AbstractChannelStrategy<OssChannelReq, OssChannelResp> getAbstractChannelStrategy(List<AbstractChannelStrategy<OssChannelReq, OssChannelResp>> abstractChannelStrategies, ChannelType channelType) {
        return abstractChannelStrategies.stream().filter(x -> x.apply(channelType)).findFirst().orElse(null);
    }
}
